package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-11-27 23:44
 **/
public class LeetCode11 {

    public int maxArea(int[] height) {
        int max = 0;
        int len = height.length;
        int start = 0;
        int end = len - 1;
        while (start < end) {
            //area: 面积
            int area = Math.min(height[start], height[end]) * (end - start);
            if (area > max) {
                max = area;
            }

            if (height[start] > height[end]) {
                end--;
            } else {
                start++;
            }
        }
        return max;
    }

}
